/*
 * @Description: 
 * @Author: Zhangx
 * @Date: 2023-08-03 15:18:30
 * @LastEditors: Zhangx
 * @LastEditTime: 2023-08-17 09:49:34
 */
export default {
  state: {
    isCollapse: false, // 定义状态(菜单的展开还是收起)
    tabsList: [
      {
        path: '/',
        name: 'home',
        label: '首页',
        icon: 'House',
        url:'Home/Home'
      }
    ] // 面包屑数据
  },
  mutations: {
    // 修改菜单收起的方法
    collapseMenu(state:any) {
      state.isCollapse = !state.isCollapse
    },
    // 更新面包屑数据
    selectMenu(state: any, val: any) {
      console.log(val, 'val222222222222')
      // 判断点击的数据是否为首页
      if (val.name !== 'home') {
        const index = state.tabsList.findIndex((item: { name: any }) => item.name === val.name)
        // 如果不存在
        if (index === -1) {
          state.tabsList.push(val)
        }
      }
    },
    // 删除指定的tag数据
    // closeTag(state, item) {
    //   const index = state.tabsList.findIndex(val => val.name === item.name)
    //   state.tabsList.splice(index,1)
    // }
    closeTag(state: { tabsList: any[] }, item: { name: any }) {
      const index = state.tabsList.findIndex(val => val.name === item.name)
      state.tabsList.splice(index,1)
    },
  }
}